using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using System.IO;

namespace LocalizeMe.ResourceTool.VSTools
{
    class VSItem
    {
        private string _name;
		private string _filePath;
		private bool _isFolder;
        private Collection<VSItem> _subItems;
        private string _code;

        public string Code
        {
            get
            {
                return _code;
            }
            set
            {
                _code = value;
            }
        }

        public Collection<VSItem> SubItems
        {
            get
            {
                if(_subItems==null)
                    _subItems=new Collection<VSItem>();
                return _subItems;
            }
        }

		public bool IsFolder
		{
			get
			{
				return _isFolder;
			}
		}

		public string FilePath
		{
			get
			{
				return _filePath;
			}
		}

		public string Name
		{
			get
			{
				return _name;
			}
		}

		public VSItem(string name,string filePath,bool isFolder)
		{
			_name = name;
			_filePath=filePath;
			_isFolder = isFolder;

            ReadCode();
		}

        private void ReadCode()
        {
            if (!string.IsNullOrEmpty(_filePath))
            {
                StreamReader sr = new StreamReader(_filePath);
                this.Code = sr.ReadToEnd();
                sr.Dispose();
            }
        }
	}
}
